home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / Components.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-11  |  11.2 KB  |  304 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Components.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __COMPONENTS__
  18. #define __COMPONENTS__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __MIXEDMODE__
  27. #include <MixedMode.h>
  28. #endif
  29.  
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33.  
  34. #if GENERATINGPOWERPC
  35. #pragma options align=mac68k
  36. #endif
  37.  
  38. #ifdef __CFM68K__
  39. #pragma lib_export on
  40. #endif
  41.  
  42.  
  43. enum {
  44.     kAppleManufacturer            = 'appl',                        /* Apple supplied components */
  45.     kComponentResourceType        = 'thng'
  46. };
  47.  
  48. enum {
  49.     kAnyComponentType            = 0,
  50.     kAnyComponentSubType        = 0,
  51.     kAnyComponentManufacturer    = 0,
  52.     kAnyComponentFlagsMask        = 0
  53. };
  54.  
  55. enum {
  56.     cmpWantsRegisterMessage        = 1L << 31
  57. };
  58.  
  59. enum {
  60.     kComponentOpenSelect        = -1,                            /* ComponentInstance for this open */
  61.     kComponentCloseSelect        = -2,                            /* ComponentInstance for this close */
  62.     kComponentCanDoSelect        = -3,                            /* selector # being queried */
  63.     kComponentVersionSelect        = -4,                            /* no params */
  64.     kComponentRegisterSelect    = -5,                            /* no params */
  65.     kComponentTargetSelect        = -6,                            /* ComponentInstance for top of call chain */
  66.     kComponentUnregisterSelect    = -7                            /* no params */
  67. };
  68.  
  69. /* Component Resource Extension flags */
  70. enum {
  71.     componentDoAutoVersion        = (1 << 0),
  72.     componentWantsUnregister    = (1 << 1),
  73.     componentAutoVersionIncludeFlags = (1 << 2),
  74.     componentHasMultiplePlatforms = (1 << 3)
  75. };
  76.  
  77. /* Set Default Component flags */
  78. enum {
  79.     defaultComponentIdentical    = 0,
  80.     defaultComponentAnyFlags    = 1,
  81.     defaultComponentAnyManufacturer = 2,
  82.     defaultComponentAnySubType    = 4,
  83.     defaultComponentAnyFlagsAnyManufacturer = (defaultComponentAnyFlags + defaultComponentAnyManufacturer),
  84.     defaultComponentAnyFlagsAnyManufacturerAnySubType = (defaultComponentAnyFlags + defaultComponentAnyManufacturer + defaultComponentAnySubType)
  85. };
  86.  
  87. /* RegisterComponentResource flags */
  88. enum {
  89.     registerComponentGlobal        = 1,
  90.     registerComponentNoDuplicates = 2,
  91.     registerComponentAfterExisting = 4
  92. };
  93.  
  94. struct ComponentDescription {
  95.     OSType                            componentType;                /* A unique 4-byte code indentifying the command set */
  96.     OSType                            componentSubType;            /* Particular flavor of this instance */
  97.     OSType                            componentManufacturer;        /* Vendor indentification */
  98.     unsigned long                    componentFlags;                /* 8 each for Component,Type,SubType,Manuf/revision */
  99.     unsigned long                    componentFlagsMask;            /* Mask for specifying which flags to consider in search, zero during registration */
  100. };
  101. typedef struct ComponentDescription ComponentDescription;
  102.  
  103. struct ResourceSpec {
  104.     OSType                            resType;                    /* 4-byte code  */
  105.     short                            resID;
  106. };
  107. typedef struct ResourceSpec ResourceSpec;
  108.  
  109. struct ComponentResource {
  110.     ComponentDescription            cd;                            /* Registration parameters */
  111.     ResourceSpec                    component;                    /* resource where Component code is found */
  112.     ResourceSpec                    componentName;                /* name string resource */
  113.     ResourceSpec                    componentInfo;                /* info string resource */
  114.     ResourceSpec                    componentIcon;                /* icon resource */
  115. };
  116. typedef struct ComponentResource ComponentResource;
  117.  
  118. typedef ComponentResource *ComponentResourcePtr, **ComponentResourceHandle;
  119.  
  120. struct ComponentPlatformInfo {
  121.     long                            componentFlags;                /* flags of Component */
  122.     ResourceSpec                    component;                    /* resource where Component code is found */
  123.     short                            platformType;                /* gestaltSysArchitecture result */
  124. };
  125. typedef struct ComponentPlatformInfo ComponentPlatformInfo;
  126.  
  127. struct ComponentResourceExtension {
  128.     long                            componentVersion;            /* version of Component */
  129.     long                            componentRegisterFlags;        /* flags for registration */
  130.     short                            componentIconFamily;        /* resource id of Icon Family */
  131. };
  132. typedef struct ComponentResourceExtension ComponentResourceExtension;
  133.  
  134. struct ComponentPlatformInfoArray {
  135.     long                            count;
  136.     ComponentPlatformInfo            platformArray[1];
  137. };
  138. typedef struct ComponentPlatformInfoArray ComponentPlatformInfoArray;
  139.  
  140. struct ExtComponentResource {
  141.     ComponentDescription            cd;                            /* registration parameters */
  142.     ResourceSpec                    component;                    /* resource where Component code is found */
  143.     ResourceSpec                    componentName;                /* name string resource */
  144.     ResourceSpec                    componentInfo;                /* info string resource */
  145.     ResourceSpec                    componentIcon;                /* icon resource */
  146.     long                            componentVersion;            /* version of Component */
  147.     long                            componentRegisterFlags;        /* flags for registration */
  148.     short                            componentIconFamily;        /* resource id of Icon Family */
  149.     long                            count;                        /* elements in platformArray */
  150.     ComponentPlatformInfo            platformArray[1];
  151. };
  152. typedef struct ExtComponentResource ExtComponentResource;
  153.  
  154. struct ComponentParameters {
  155.     unsigned char                    flags;                        /* call modifiers: sync/async, deferred, immed, etc */
  156.     unsigned char                    paramSize;                    /* size in bytes of actual parameters passed to this call */
  157.     short                            what;                        /* routine selector, negative for Component management calls */
  158.     long                            params[1];                    /* actual parameters for the indicated routine */
  159. };
  160. typedef struct ComponentParameters ComponentParameters;
  161.  
  162. struct ComponentRecord {
  163.     long                            data[1];
  164. };
  165. typedef struct ComponentRecord ComponentRecord;
  166.  
  167. typedef ComponentRecord *Component;
  168.  
  169. struct ComponentInstanceRecord {
  170.     long                            data[1];
  171. };
  172. typedef struct ComponentInstanceRecord ComponentInstanceRecord;
  173.  
  174. typedef ComponentInstanceRecord *ComponentInstance;
  175.  
  176. typedef long ComponentResult;
  177.  
  178. typedef pascal ComponentResult (*ComponentRoutineProcPtr)(ComponentParameters *cp, Handle componentStorage);
  179.  
  180. #if GENERATINGCFM
  181. typedef UniversalProcPtr ComponentRoutineUPP;
  182. #else
  183. typedef ComponentRoutineProcPtr ComponentRoutineUPP;
  184. #endif
  185.  
  186. enum {
  187.     uppComponentRoutineProcInfo = kPascalStackBased
  188.          | RESULT_SIZE(SIZE_CODE(sizeof(ComponentResult)))
  189.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(ComponentParameters*)))
  190.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Handle)))
  191. };
  192.  
  193. #if GENERATINGCFM
  194. #define NewComponentRoutineProc(userRoutine)        \
  195.         (ComponentRoutineUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppComponentRoutineProcInfo, GetCurrentArchitecture())
  196. #else
  197. #define NewComponentRoutineProc(userRoutine)        \
  198.         ((ComponentRoutineUPP) (userRoutine))
  199. #endif
  200.  
  201. #if GENERATINGCFM
  202. #define CallComponentRoutineProc(userRoutine, cp, componentStorage)        \
  203.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppComponentRoutineProcInfo, (cp), (componentStorage))
  204. #else
  205. #define CallComponentRoutineProc(userRoutine, cp, componentStorage)        \
  206.         (*(userRoutine))((cp), (componentStorage))
  207. #endif
  208.  
  209. typedef ComponentRoutineProcPtr ComponentRoutine;
  210.  
  211. /*
  212.     The parameter list for each ComponentFunction is unique. It is 
  213.     therefore up to users to create the appropriate procInfo for their 
  214.     own ComponentFunctions where necessary.
  215. */
  216. typedef UniversalProcPtr ComponentFunctionUPP;
  217.  
  218. #define ComponentCallNow( callNumber, paramSize ) \
  219.     FIVEWORDINLINE( 0x2F3C,paramSize,callNumber,0x7000,0xA82A )
  220.  
  221. extern pascal Component RegisterComponent(ComponentDescription *cd, ComponentRoutineUPP componentEntryPoint, short global, Handle componentName, Handle componentInfo, Handle componentIcon)
  222.  TWOWORDINLINE(0x7001, 0xA82A);
  223. extern pascal Component RegisterComponentResource(ComponentResourceHandle tr, short global)
  224.  TWOWORDINLINE(0x7012, 0xA82A);
  225. extern pascal OSErr UnregisterComponent(Component aComponent)
  226.  TWOWORDINLINE(0x7002, 0xA82A);
  227. extern pascal Component FindNextComponent(Component aComponent, ComponentDescription *looking)
  228.  TWOWORDINLINE(0x7004, 0xA82A);
  229. extern pascal long CountComponents(ComponentDescription *looking)
  230.  TWOWORDINLINE(0x7003, 0xA82A);
  231. extern pascal OSErr GetComponentInfo(Component aComponent, ComponentDescription *cd, Handle componentName, Handle componentInfo, Handle componentIcon)
  232.  TWOWORDINLINE(0x7005, 0xA82A);
  233. extern pascal long GetComponentListModSeed(void)
  234.  TWOWORDINLINE(0x7006, 0xA82A);
  235. /* Component Instance Allocation and dispatch routines */
  236. extern pascal ComponentInstance OpenComponent(Component aComponent)
  237.  TWOWORDINLINE(0x7007, 0xA82A);
  238. extern pascal OSErr CloseComponent(ComponentInstance aComponentInstance)
  239.  TWOWORDINLINE(0x7008, 0xA82A);
  240. extern pascal OSErr GetComponentInstanceError(ComponentInstance aComponentInstance)
  241.  TWOWORDINLINE(0x700A, 0xA82A);
  242. /* Direct calls to the Components */
  243. extern pascal long ComponentFunctionImplemented(ComponentInstance ci, short ftnNumber)
  244.  FIVEWORDINLINE(0x2F3C, 0x2, 0xFFFD, 0x7000, 0xA82A);
  245. extern pascal long GetComponentVersion(ComponentInstance ci)
  246.  FIVEWORDINLINE(0x2F3C, 0x0, 0xFFFC, 0x7000, 0xA82A);
  247. extern pascal long ComponentSetTarget(ComponentInstance ci, ComponentInstance target)
  248.  FIVEWORDINLINE(0x2F3C, 0x4, 0xFFFA, 0x7000, 0xA82A);
  249. /* Component Management routines */
  250. extern pascal void SetComponentInstanceError(ComponentInstance aComponentInstance, OSErr theError)
  251.  TWOWORDINLINE(0x700B, 0xA82A);
  252. extern pascal long GetComponentRefcon(Component aComponent)
  253.  TWOWORDINLINE(0x7010, 0xA82A);
  254. extern pascal void SetComponentRefcon(Component aComponent, long theRefcon)
  255.  TWOWORDINLINE(0x7011, 0xA82A);
  256. extern pascal short OpenComponentResFile(Component aComponent)
  257.  TWOWORDINLINE(0x7015, 0xA82A);
  258. extern pascal OSErr CloseComponentResFile(short refnum)
  259.  TWOWORDINLINE(0x7018, 0xA82A);
  260. /* Component Instance Management routines */
  261. extern pascal Handle GetComponentInstanceStorage(ComponentInstance aComponentInstance)
  262.  TWOWORDINLINE(0x700C, 0xA82A);
  263. extern pascal void SetComponentInstanceStorage(ComponentInstance aComponentInstance, Handle theStorage)
  264.  TWOWORDINLINE(0x700D, 0xA82A);
  265. extern pascal long GetComponentInstanceA5(ComponentInstance aComponentInstance)
  266.  TWOWORDINLINE(0x700E, 0xA82A);
  267. extern pascal void SetComponentInstanceA5(ComponentInstance aComponentInstance, long theA5)
  268.  TWOWORDINLINE(0x700F, 0xA82A);
  269. extern pascal long CountComponentInstances(Component aComponent)
  270.  TWOWORDINLINE(0x7013, 0xA82A);
  271. /* Useful helper routines for convenient method dispatching */
  272. extern pascal long CallComponentFunction(ComponentParameters *params, ComponentFunctionUPP func)
  273.  TWOWORDINLINE(0x70FF, 0xA82A);
  274. extern pascal long CallComponentFunctionWithStorage(Handle storage, ComponentParameters *params, ComponentFunctionUPP func)
  275.  TWOWORDINLINE(0x70FF, 0xA82A);
  276. extern pascal long DelegateComponentCall(ComponentParameters *originalParams, ComponentInstance ci)
  277.  TWOWORDINLINE(0x7024, 0xA82A);
  278. extern pascal OSErr SetDefaultComponent(Component aComponent, short flags)
  279.  TWOWORDINLINE(0x701E, 0xA82A);
  280. extern pascal ComponentInstance OpenDefaultComponent(OSType componentType, OSType componentSubType)
  281.  TWOWORDINLINE(0x7021, 0xA82A);
  282. extern pascal Component CaptureComponent(Component capturedComponent, Component capturingComponent)
  283.  TWOWORDINLINE(0x701C, 0xA82A);
  284. extern pascal OSErr UncaptureComponent(Component aComponent)
  285.  TWOWORDINLINE(0x701D, 0xA82A);
  286. extern pascal long RegisterComponentResourceFile(short resRefNum, short global)
  287.  TWOWORDINLINE(0x7014, 0xA82A);
  288. extern pascal OSErr GetComponentIconSuite(Component aComponent, Handle *iconSuite)
  289.  TWOWORDINLINE(0x7029, 0xA82A);
  290.  
  291. #ifdef __CFM68K__
  292. #pragma lib_export off
  293. #endif
  294.  
  295. #if GENERATINGPOWERPC
  296. #pragma options align=reset
  297. #endif
  298.  
  299. #ifdef __cplusplus
  300. }
  301. #endif
  302.  
  303. #endif /* __COMPONENTS__ */
  304.